﻿using LXYYY.EntityFrameworkCore;
using LXYYY.IRBACService;
using LXYYY.Models;
using LXYYY.RBACDTO;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace LXYYY.RBACService
{
    public class MenuService : ApplicationService, IMenuService
    {
        LXYYYDbContext pp;
        public MenuService(LXYYYDbContext _pp)
        {
            pp = _pp;
        }
        [HttpGet]
        [Route("DDDD")]
        public List<MenuDTO> MenuShow(int id)
        {
            var list = pp.Power.ToList();
            return DiGui(list, id);
        }
        private List<MenuDTO> DiGui(List<Power> powers, int id)
        {
            var list = pp.Power.ToList();
            var _list = list.Where(x => x.PowerDesc == id).ToList();
            List<MenuDTO> menuDTO = new List<MenuDTO>();
            _list.ForEach(x =>
            {

                menuDTO.Add(new MenuDTO()
                {
                    Id = x.Id.ToString(),
                    PowerDesc = x.PowerDesc,
                    PowerName = x.PowerName,
                    menuDTOs = DiGui(powers, x.Id)
                });
            });
            return menuDTO;
        }
    }
}
